<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Collect extends Model
{
    use SoftDeletes;

    protected $fillable = ['title', 'introduction', 'user_id', 'view_count'];

    // 看单包含的电影
    public function movies()
    {
        return $this->belongsToMany(Movie::class);
    }

    // 看单创建者
    public function author()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
    // 关注(打卡操作)看单的人
    public function follwers()
    {
        return $this->belongsToMany(User::class, 'collect_user', 'collect_id', 'user_id');
    }

}
